@时光机
3年前 提问
1个回答

Apache 怎么样配置 CGI

在下炳尚
3年前
官方采纳

前提是系统安装好Apache(这里介绍的版本以2.0.63为例),下载一个编译器,这些准备工作干完以后开始配置。

  1. 修改apache的配置文件httpd.conf:

    <Directory "D:/Apache Group/Apache2/cgi-bin">
     AllowOverride None
     Options None
     Order allow,deny
     Allow from all
    </Directory>
    #AddHandler cgi-script .cgi
    改为:
    <Directory "D:/Apache Group/Apache2/cgi-bin">
     AllowOverride None
     Options ExecCGI
     Order allow,deny
     Allow from all
    </Directory>
    AddHandler cgi-script .cgi .pl
  2. 编写perl脚本程序hello.pl

#!C:Perlbinperl.exe
print "content-type: text/html","nn";
print "<HTML>","n";
print "<HEAD>","n";
print "<TITLE>Perl</TITLE>","n";
print "</HEAD>","n";
print "<BODY>","n";
print "<H1>Hello World</H1>","n";
print "</BODY>","n";
print "</HTML>","n";

将程序拷贝到apache安装目录下cgi-bin文件夹下.

  1. 启动Apache服务器,打开浏览器输入http://127.0.0.1/cig-bin/hello.pl后页面显示“Hello World”后说明配置成功。